package com.mes.device.controller;

import com.mes.common.pojo.MESResult;
import com.mes.device.server.DeviceServer;
import com.mes.pojo.device.Device;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 张喆
 * @Company
 * @Description
 * @Time 2024/10/17 18:40
 */
@RestController
@CrossOrigin
@RequestMapping("/device")
public class DeviceController {
    @Autowired
    private DeviceServer deviceServer;
    @GetMapping("/list")
    public MESResult list(Device device, @RequestParam(defaultValue = "1") Integer pageNum,@RequestParam(defaultValue = "10") Integer limit){
        return deviceServer.queryAll(device,pageNum,limit);
    }
    @GetMapping("/export")
    public MESResult export(Device device, @RequestParam(defaultValue = "1") Integer pageNum,@RequestParam(defaultValue = "10") Integer limit){
        return deviceServer.getExport(device,pageNum,limit);
    }
    @GetMapping("/getUpdate")
    public MESResult updateInfo(String deviceId){
        return deviceServer.queryByDeviceId(deviceId);
    }
    @DeleteMapping("/delete")
    public MESResult deleteDevice(String deviceId){
        return deviceServer.deleteDevice(deviceId);
    }
    @PutMapping("/update")
    public MESResult update(@RequestBody Device device){
        return deviceServer.updateDevice(device);
    }
    @PostMapping("/insert")
    public MESResult insert(@RequestBody Device device){
        return deviceServer.addNewDevice(device);
    }
}
